#include <iostream>
using namespace std;

const int kMaxN = 1e5 + 10;

int t[kMaxN], p[kMaxN], a[kMaxN], diff[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  int ans = 0;
  for (int i = 1; i <= n + 1; i++) {
    a[i] = p[i] - t[i];
    diff[i] = a[i] - a[i - 1];
    if (diff[i] > 0) {
      ans += diff[i];
    }
  }
  cout << ans << "\n";
  return 0;
}